/*
 * JsonObject.h
 *
 *  Created on: Jun 2, 2011
 *      Author: ToanNhan
 */

#ifndef JSONOBJECT_H_
#define JSONOBJECT_H_

#include "JsonValue.h"
#include "FBase.h"
#include "vector"

using namespace Osp::Base;
using namespace Osp::Base::Collection;
using namespace std;



class JsonObject : public JsonValue {
public:
	const static mchar beginChar = '{';
	const static mchar endChar = '}';
public:
	class Member{
		private:
			String key;
			JsonValue *value;
		public:
			Member();
			Member(String key, JsonValue *value);
			Member(const Member& member);
			~Member();
			const Member& operator =(const Member& member);

			void setKey(String key);
			void setValue(JsonValue *value);
			String getKey();
			JsonValue* getValueN();
			String toJsonString();
	};
protected:
	vector<Member> members;

	//override
public:
	JsonObject* cloneN();
public:

	int getSize();

	JsonValue* getValueN(String key);
	JsonValue* getValueN(int index);

	void insertValue(String key, JsonValue* value);
	void insertValue(JsonObject::Member member);

	String toJsonString();

	JsonObject();
	virtual ~JsonObject();
};

#endif /* JSONOBJECT_H_ */
